package fun.asgc.boot.netty.web.test1;

import fun.asgc.boot.netty.annotation.Configuration;
import fun.asgc.boot.netty.web.config.WebMvcConfigurer;
import fun.asgc.boot.netty.web.interceptor.ExceptionHandlerRegistry;
import fun.asgc.boot.netty.web.interceptor.InterceptorRegistry;
import fun.asgc.boot.netty.web.interceptor.RestControllerAdviceHandler;

/**
 *
 * @author: aoshiguchen
 * @date: 2022/7/28
 */
@Configuration
public class WebConfigurerAdapter implements WebMvcConfigurer {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new BaseAuthInterceptor())
			.addPathPatterns("/**").excludePathPatterns("/**/*.html", "/**/*.js", "/**/*.ico");
	}

	@Override
	public void addExceptionHandler(ExceptionHandlerRegistry registry) {
		registry.addExceptionHandler(new GlobalExceptionHandler());
	}

	@Override
	public RestControllerAdviceHandler adviceHandler() {
		return new GlobalAdviceHandler();
	}
}
